{extend name="common/base" /}
{block name="title"}系统首页{/block}
{block name="css"}
<link href="{__ADMIN_JS__}js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="{__ADMIN_JS__}js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
{/block}
{block name="body"}
<div class="container-fluid p-t-15">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">

                    <form onsubmit="return false" action="#!" method="post" class="login-form" id="form1">
                        <div class="form-group">
                            <label for="oldPsw">旧密码</label>
                            <input type="password" class="form-control" name="oldPsw" id="oldPsw" placeholder="输入账号的原登录密码">
                        </div>
                        <div class="form-group">
                            <label for="newpassword">新密码</label>
                            <input type="password" class="form-control" name="newpassword" id="newpassword" placeholder="输入新的密码">
                        </div>
                        <div class="form-group">
                            <label for="repassword">确认新密码</label>
                            <input type="password" class="form-control" name="repassword" id="repassword" placeholder="请输入正确的邮箱地址">
                        </div>
                        <button type="submit" class="btn btn-primary" onclick="submits()">修改密码</button>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="{__ADMIN_JS__}js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="{__ADMIN_JS__}js/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="{__ADMIN_JS__}js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<!--以下是tree-grid的使用示例-->
<link href="{__ADMIN_JS__}js/jquery-treegrid/jquery.treegrid.min.css" rel="stylesheet">
<script type="text/javascript" src="{__ADMIN_JS__}js/jquery-treegrid/jquery.treegrid.min.js"></script>
<script type="text/javascript" src="{__ADMIN_JS__}js/bootstrap-table/extensions/treegrid/bootstrap-table-treegrid.min.js"></script>
{/block}
{block name="script"}
<script type="text/javascript">
    function submits() {
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/admin/tpl/password" ,//url
            data: $('#form1').serialize(),
            success: function (res) {
                console.log(res);//打印服务端返回的数据(调试用)
                if (res.code === 0) {
                    $.alert({
                        title: '成功',
                        icon: 'mdi mdi-alert',
                        type: 'blue',
                        content: res.msg,
                        buttons: {
                            okay: {
                                text: '确认',
                                btnClass: 'btn-blue',
                                action: function() {

                                }
                            }
                        }
                    });
                }else {
                    $.alert({
                        title: '错误',
                        icon: 'mdi mdi-alert',
                        type: 'red',
                        content: res.msg,
                        buttons: {
                            okay: {
                                text: '确认',
                                btnClass: 'btn-blue',
                                action: function() {
                                    $('[alt="captcha"]').click();
                                }
                            }
                        }
                    });
                };
            },
            error : function() {
                $.alert({
                    title: '警告',
                    content: '请检查返回是否正常！',
                    icon: 'mdi mdi-access-point-network-off',
                    animation: 'scale',
                    closeAnimation: 'scale',
                    buttons: {
                        okay: {
                            text: '确认',
                            btnClass: 'btn-blue'
                        }
                    }
                });
            }
        });
    }
</script>
{/block}